package com.zhengdongzulin.zuke.widget.banner

import android.content.Context
import android.util.AttributeSet
import android.widget.ImageView
import android.widget.LinearLayout
import com.bumptech.glide.Glide
import com.xuexiang.xui.widget.banner.widget.banner.BannerItem
import com.xuexiang.xui.widget.banner.widget.banner.base.BaseImageBanner
import com.zhengdongzulin.zuke.R

/**
 * 简单的图片轮播
 *  jeff
 *  2021-05-13 09:50:56
 */
class Banner : BaseImageBanner<Banner?> {
    constructor(context: Context?) : super(context) {}
    constructor(context: Context?, attrs: AttributeSet?) : super(context, attrs) {}
    constructor(context: Context?, attrs: AttributeSet?, defStyle: Int) : super(
        context,
        attrs,
        defStyle
    ) {
    }

    override fun getItemLayoutId(): Int {
        return R.layout.xui_adapter_simple_image
    }

    override fun getImageViewId(): Int {
        return R.id.iv
    }

    override fun loadingImageView(iv: ImageView, item: BannerItem) {
        val itemWidth = itemWidth
        val itemHeight = itemHeight
        iv.scaleType = ImageView.ScaleType.FIT_XY
        iv.layoutParams = LinearLayout.LayoutParams(itemWidth, itemHeight)
        Glide.with(context).load(item.imgUrl).error(com.zhengdongzulin.zuke.R.mipmap.error_empty_zheng).placeholder(com.zhengdongzulin.zuke.R.mipmap.error_empty_zheng).into(iv)
    }
}